import JSEncrypt from 'jsencrypt';

const PUB_KEY =
  'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnTME/WFHmww0B0+iPPEk+yj6UFLzVcrPL/wBa+DecSVyT6eSs7zWH6byzDDh//JejPt/Xqule0a70vv7l2cYCvuP1/0J+JJopJM4dxGGfjVi0pgHhk5aINTGMTs4n7Hd5ZMTR2LVNixrDTJ1YAHL6WWLw4qMKc76SH/ze/KFi0QIDAQAB';

// 公钥加密
export function encrypt(text: string): string {
  const encrypt = new JSEncrypt();
  encrypt.setPublicKey(PUB_KEY);
  const encrypted = encrypt.encrypt(text);

  if (encrypted.toString() == 'false') {
    return '';
  } else {
    return encrypted.toString();
  }
}
